import 'package:find_friend/const/const.dart';
import 'package:find_friend/pages/login&register/model/shared_user_info.dart';
import 'package:find_friend/pages/mine/mine_setting/setting_modmobileby_sms.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'mine_setting.dart' show MineSettingCell;

class MineSettingAccountPage extends StatefulWidget {
  @override
  _MineSettingAccountPageState createState() => _MineSettingAccountPageState();
}

class _MineSettingAccountPageState extends State<MineSettingAccountPage> {

  SharedUserInfo _userInfo = SharedUserInfo();

  @override
  void initState() {
    super.initState();

    _initData();
  }

  _initData() async {
    final user = await SharedUserInfo.instance();
    _userInfo = user;
    if(mounted) setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("账号管理"),
        backgroundColor: Colors.white,
        centerTitle: true,
        leading: IconButton(
          onPressed: (){
            Navigator.of(context).pop();
          },
          icon: Image.asset("assets/fanhui.png"),
        ),
      ),
      body: Column(
        children: [
          MineSettingCell("手机号绑定",detail: _userInfo.mobile ?? "",callback: () => Navigator.of(context).pushNamed("/settingmodphone")),
          MineSettingCell("学号",detail: _userInfo.idcard ?? "暂未绑定",),
          MineSettingCell("修改密码",callback: (){
            if(_userInfo.password == true) {
               Navigator.of(context).pushNamed("/settingmodpwd");
            } else {
              push(context, SettingModMobleBySmsPage(phone: _userInfo.mobile));
            }
          }),
        ],
      ),
    );
  }
}